/* styles-common.css */

:root {
  --primary-color: #3498db;
  --secondary-color: #2c3e50;
  --background-color: #6a89a3;
  --card-background: #ffffff;
  --text-color: #333333;
  --border-color: #e2e8f0;
  --success-color: #2ecc71;
  --danger-color: #e74c3c;
  --border-radius: 8px;
  --left-panel-width: 280px;
  --gap-size: 1px;
  --container-padding: 1px;
  --footer-height: 20px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05);
  --transition-normal: all 0.2s ease;
  --header-height: 48px;
}

/* 基础重置 */
body, html {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: var(--background-color);
  color: var(--text-color);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* 主容器布局 */
.robot-simulation-ui {
  gap: var(--gap-size);  /* 分隔区域 */
  min-height: 100vh;
  height: 100vh;
  display: flex;
  overflow: hidden;
  position: relative;
  padding-bottom: var(--footer-height);
}

/* 左侧容器 */
.left-panel-container {
  width: var(--left-panel-width);
  padding: var(--container-padding);
  height: 100%;
  transition: all 0.3s ease;
  position: relative;
  flex-shrink: 0;
  /* background: var(--card-background); */
  border-right: 1px solid var(--border-color);
}

/* 左侧面板 */
.left-panel-container.collapsed {
  width: 10px;
}

/* 左侧固定面板 */
.left-fixed-panel {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1px;
  transition: opacity 0.3s ease;
  opacity: 1;
}

/* 左侧固定面板折叠 */
.left-panel-container.collapsed .left-fixed-panel {
  opacity: 0.5;
  backdrop-filter: blur(8px);
  background-color: rgba(255, 255, 255, 0.9); /* 添加半透明背景 */
  pointer-events: none;
  transition: all 0.3s ease;
}

.left-panel-container.collapsed::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
      to right,
      rgba(255, 255, 255, 0.1),
      rgba(255, 255, 255, 0.2)
  );
  pointer-events: none;
}

/* 折叠按钮 */
.panel-collapse-button {
  position: absolute;
  right: -8px; /* 稍微调整位置 */
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 86px; /* 增加高度 */
  padding: 0;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 7px; /* 长圆角 */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-normal);
}

.panel-collapse-button:hover {
  background: var(--primary-color);
  color: white;
  transform: translateY(-50%) scale(1.05);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.panel-collapse-button i {
  transition: transform 0.3s ease;
}

.panel-collapse-button [data-lucide="chevron-left"],
.panel-collapse-button [data-lucide="chevron-right"] {
    width: 20px;   /* 增大图标尺寸 */
    height: 20px;
    stroke-width: 2.5px;  /* 增加线条粗细 */
    color: var(--primary-color);  /* 使用主题色 */
    transition: all 0.3s ease;
}

.panel-collapse-button:hover [data-lucide="chevron-left"],
.panel-collapse-button:hover [data-lucide="chevron-right"] {
    color: white;  /* 悬浮时图标变白 */
    stroke-width: 3px;  /* 悬浮时线条更粗 */
}

/* 折叠状态图标旋转 */
.left-panel-container.collapsed .panel-collapse-button [data-lucide="chevron-left"] {
    transform: rotate(180deg);
}

/* 图标基础样式 */
[data-lucide] {
  width: 13px;
  height: 13px;
  stroke: #0963f4;  /* 统一使用蓝色 */
  stroke-width: 3; /* 线条粗细 */
  fill: none;       /* 确保图标是空心的 */
  color: #60a5fa;
}

/* Logo 部分的图标可以单独设置颜色 */
.logo-section [data-lucide] {
  color: #60a5fa; /* 蓝色 */
}

/* 不同状态下的颜色变化 */
.logo-section.error [data-lucide] {
  color: #ef4444; /* 错误状态红色 */
}

.logo-section.working [data-lucide] {
  color: #22c55e; /* 工作状态绿色 */
}

/* 主内容区域 */
.center-panel-container {
  display: flex;
  padding: var(--container-padding);
  flex-direction: column; /* 改为纵向布局 */
  flex: 1;
  gap: 2px;
  overflow: hidden;
  min-width: 0;
  transition: all 0.3s ease;
  position: relative;
  margin-right: -1px; /* 抵消右边框 */
}

/* 主视图区域 */
.main-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0; /* 允许压缩 */
  background: var(--card-background);
  border-radius: var(--border-radius);
  overflow: hidden;
  position: relative;
  margin-right: -4px; /* 负边距使手柄贴合 */
  margin-bottom: -3px; /* 负边距使手柄贴合 */
  padding: var(--container-padding);
}

/* 主内容区域 */
.content-area {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  margin: 0; /* 确保没有margin */
  padding: var(--container-padding);
}

.content-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
}

.content-panel.active {
  display: flex;
}

/* 3D世界容器 */
#world-3d-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;  /* 确保填满容器 */
  height: 100%;
  background: #f5f5f5;
}

/* 左侧可调整面板 */
.left-adjustable-panel {
  width: 290px;
  min-width: 200px;
  max-width: 600px;
  display: flex;
  background: var(--card-background);
  border-radius: var(--border-radius);
  position: relative;
}

.panel-content {
  flex: 1;
  overflow: auto;
  padding: 16px;
}

/* 通用手柄基础样式 */
.resize-handle-vertical,
.resize-handle-horizontal {
  position: absolute;
  background: #c324cb;
  transition: background-color 0.2s;
  z-index: 10;
  margin: 0; /* 移除任何margin */
}

/* 垂直手柄特殊样式 */
.resize-handle-vertical {
  right: 3px;
  top: 0;
  width: 2px;
  height: 100%;
  cursor: col-resize;
}

/* 水平手柄特殊样式 */
.resize-handle-horizontal {
  position: relative;
  width: 100%;
  height: 2px;
  margin-top: 0px;
  cursor: row-resize;
}

/* 共用悬停效果 */
.resize-handle-vertical:hover,
.resize-handle-vertical.active,
.resize-handle-horizontal:hover,
.resize-handle-horizontal.active {
  background: #031d78;
}

/* 世界内容容器 */
#world-content {
  position: relative;
  height: 100%;
  background: var(--card-background);
  border-radius: var(--border-radius);
  overflow: hidden;
}

/* 导航栏容器 */
.nav-buttons {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 40px;
  background: rgba(255, 255, 255, 0.1);  /* 更透明的背景 */
  backdrop-filter: blur(1px);  /* 毛玻璃效果 */
  display: flex;
  flex-direction: column;
  padding: 4px 0;
  gap: 2px;
  z-index: 20;
}

/* 按钮基础样式 */
.nav-button {
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  background: transparent;
  color: #666666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.2s;
}

.nav-button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--primary-color);
}

.nav-button.active {
  color: var(--primary-color);
}

.nav-button::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: transparent;
  transition: background-color 0.2s;
}

.nav-button.active::before {
  background: var(--primary-color);
}

/* 图标大小调整 */
.nav-button svg {
  width: 20px;
  height: 20px;
}

/* 工具提示 */
.nav-button[data-tooltip] {
  position: relative;
}

.nav-button[data-tooltip]:before {
  content: attr(data-tooltip);
  position: absolute;
  left: 46px;
  top: 50%;
  transform: translateY(-50%);

  /* 文字相关 */
  font-size: 12px;
  line-height: 1;  /* 设为1，确保文字紧凑 */
  white-space: nowrap;  /* 保持单行 */

  /* 盒模型调整 */
  display: flex;  /* 使用flex布局让内容居中 */
  align-items: center;  /* 垂直居中 */
  justify-content: center;  /* 水平居中 */
  height: 24px;  /* 固定高度 */
  width: 70px;  /* 固定高度 */
  padding: 0 10px;  /* 水平方向留出空间 */
  box-sizing: border-box;  /* 确保padding包含在高度内 */

  /* 视觉效果 */
  background: rgba(64, 64, 64, 0.95);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);

  /* 动画相关 */
  opacity: 0;
  visibility: hidden;
  transition: all 0.15s ease;
  pointer-events: none;
  z-index: 1000;
}

/* 提示框左侧小三角 */
.nav-button[data-tooltip]:after {
  content: '';
  position: absolute;
  left: 40px;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: rgba(64, 64, 64, 0.95);  /* 匹配提示框背景色 */
  opacity: 0;
  visibility: hidden;
  transition: all 0.15s ease;
  pointer-events: none;
}

/* 显示提示和小三角 */
.nav-button[data-tooltip]:hover:before,
.nav-button[data-tooltip]:hover:after {
  opacity: 1;
  visibility: visible;
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--background-color);
}

::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* 底部状态栏样式优化 */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--footer-height);
  background: var(--card-background);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}

/* 连接组样式 */
.connection-group {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;  /* 防止文字换行 */
}

#connection-status {
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--success-color);
  color: white;
  font-size: 12px;
  border: none;
  display: flex;
  align-items: center;
}

#connection-status.disconnected {
  background: var(--danger-color);
}

/* 工具提示样式 */
[data-tooltip] {
  position: relative;
}

[data-tooltip]:before {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.75);
  color: white;
  font-size: 12px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
  pointer-events: none;
  margin-left: 8px;
}

[data-tooltip]:hover:before {
  opacity: 1;
  visibility: visible;
}

/* 暗色主题变量（可选） */
[data-theme="dark"] {
  --primary-color: #60a5fa;
  --secondary-color: #475569;
  --background-color: #1e293b;
  --card-background: #334155;
  --text-color: #f1f5f9;
  --border-color: #475569;
}

/* IP地址 */
.robot-ip {
  font-family: var(--font-mono, monospace);  /* 使用等宽字体 */
  color: var(--text-color);
  white-space: nowrap;
}

.connect-settings {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  transition: all 0.2s ease;
}

/* 中间传输速度 */
.footer-center {
  display: flex;
  align-items: center;
}

.robot-settings i {
  width: 16px;
  height: 16px;
  color: var(--text-color);
}

.connect-settings:hover {
  background: var(--background-color);
}

/* 传输速度样式 */
.transfer-rate {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  white-space: nowrap;
}

.upload, .download {
  display: flex;
  align-items: center;
  gap: 4px;
}

.upload i, .download i {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

.upload { color: var(--success-color); }
.download { color: var(--primary-color); }

/* 坐标样式 */
.robot-coordinates {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: monospace;
  font-size: 13px;
  white-space: nowrap;  /* 防止换行 */
}

.coord {
  display: flex;
  align-items: center;
  gap: 4px;
}

.coord span:first-child {
  color: var(--text-color);
  opacity: 0.7;
}

.coord .value {
  font-weight: 500;
}

/* 右侧面板容器 */
.right-panel-container {
  min-width: 360px;  /* 设置一个较小的最小宽度 */
  max-width: 480px;  /* 限制最大宽度，使内容更紧凑 */
  height: 100%;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  background: var(--background-color);
  border-left: 1px solid var(--border-color);
  padding: var(--container-padding);
}

/* 右侧内容区域 */
.right-content-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 1px;
  gap: 2px;
}

/* 响应式处理 */
@media (max-width: 1280px) {
  .right-panel-container {
    width: 320px;
  }
}

@media (min-width: 1920px) {
  .right-panel-container {
    width: 480px;
  }
}